The present invention is generally related to the analysis of syntactical expressions and the generation of a mechanism which is capable of generating error messages associated with supplied syntactical expressions. More particularly, the present invention is related to a method for producing program mechanisms:
1. which generate error messages associated with a supplied set of syntactical expressions; and PA1 2. which provide recovery from errors that violate a supplied set of syntactical expressions. PA1 1. accepts and parses command line sequences, PA1 2. automatically produces error messages, and PA1 3. automatically recovers from the error in order to resume parsing. PA1 1. Accordingly, the present invention also operates to produce code which produces error messages. PA1 Moreover, these error messages are the preferred ones which would logically be associated with the attempted parsing of command sequences which are not in conformance with the grammar. PA1 2. The present invention includes error recovery methods which are also automatically entered into as a result of the detection of incorrect language command sequences. PA1 These error recovery methods determine the first possible position where parsing of the command sequences can resume.
An understanding of the present invention is perhaps best understood by first considering the normal operation of computer software programs referred to as "compilers". Compilers accept statements in a given language whose syntax is specified, and in response thereto they generate sequences of code structures. In particular, when a string of symbols from the language is supplied to the compiler and is subsequently recognized by the compiler, the output is often a list of code structures which are produced in response to the compiler having parsed the supplied input sequence from the specified language in accordance with syntax which defines the language. In accordance with the rules of the language, the compiler operates to parse the words and phrases supplied and in doing so effectively traverses a tree structure through the operation of pushing and popping various syntactical elements to and from a computer stack structure implemented in the memory of the machine on which the compiler is running. When a terminal node of a syntactical tree is reached, nonterminal elements of the syntax are replaced by terminal elements. When such a tree node is reached, the particular expression being presented to the compiler is said to have been parsed successfully and it is then possible to associate the list of syntactical expressions in accordance with the implemented language to be associated with an appropriate set of code structures which can be run on a machine for which the compiler output is designed (the target machine). Alternatively, the output of the compiler might also comprise a sequence of code structures which are construed as pseudo-code or so-called P-level code which may be relatively easily ported across a number of different hardware machine environments.
However, there are times during the compilation process when incorrect sequences are presented to the compiler. That is to say, it is possible to present to the compiler sequences of expressions which are not grammatically correct in terms of the defined syntax which the compiler is meant to implement. When this occurs, the compiler issues an error message describing the nature of the syntactical error. Furthermore, it is often the case that the occurrence of the error results in the inability of the compiler to proceed in parsing the remaining stream of input characters representing expressions and phrases from the intended grammar. For example, those who are familiar with the programming arts and/or those who have written programs in any of a large number of different computer languages are well aware of compiler generated error messages such as "the highlighted word is not a valid variable name".
In the present invention, systems' designers supply to an embodiment of the present invention a string of symbols which define the syntax for the language which is meant to be implemented. Typically, in the present invention operating system code designers supply syntactical expressions to the invention's code generator. These expressions typically describe appropriate command line formats which are to be recognized and translated into a sequence of code structures which are to be performed by the computer operating system. It is the command syntax that is typically provided to a software embodiment of the present invention. These syntactical expressions are used to create code generators which accept expressions from the language implemented (to be distinguished from syntax expressions which define the language itself). In a certain sense then the present invention is somewhat similar to a compiler compiler or a compiler generator. From syntactical definitions provided by the user, the present invention generates code which in turn accepts command line sequences and produces actual output code or output pseudo-code.